package com.oig.sys.auth.dao;

import com.oig.sys.auth.entity.TbJob;
import com.oig.sys.auth.vo.JobVo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
@author wuxl
*/
public interface ITbJobDao extends JpaRepository<TbJob, Integer>, JpaSpecificationExecutor<TbJob>{

	TbJob getTbJobById(Integer id);

    @Query("select new com.oig.sys.auth.vo.JobVo(j.id,j.jobCode,j.jobName,j.status,j.tenantId,j.tenantCode,j.tenantName,j.departId,j.departName," +
            "j.createUserName,j.createTime,j.lastUpdateName,j.lastUpdateTime) " +
            "from TbJob j where  j.id=:id")
    JobVo getVoById(@Param("id") Integer id);

	@Query("select new com.oig.sys.auth.vo.JobVo(j.id,j.jobCode,j.jobName,j.status,j.tenantId,j.tenantCode,j.tenantName,j.departId,j.departName," +
			"j.createUserName,j.createTime,j.lastUpdateName,j.lastUpdateTime) " +
			"from TbJob j where  j.id in(:idList) ")
	List<JobVo> findAllByIds(@Param("idList") List<Integer> idList);

}
